﻿using Marmat.Common.Http;
using System;

namespace Marmat.FrameWork
{
    /// <summary>
    /// Http接口代理的扩展函数。
    /// </summary>
    public static class HttpFactoryExtension
    {
        /// <summary>
        /// 创建Http接口请求代理。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static T HttpApi<T>(this Marmat.Foundation.IProvider provider) where T : class
        {
            return Marmat.Common.Http.HttpFactory.Create<T>();
        }

        /// <summary>
        /// 创建Http接口请求代理。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="provider"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static T HttpApi<T>(this Marmat.Foundation.IProvider provider, Action<HttpApiConfig> action) where T : class
        {
            return Marmat.Common.Http.HttpFactory.Create<T>(action);
        }
    }
}
